﻿
using System.Windows;
using YY.Admin.ViewModels.Login;
using YY.Admin.ViewModels;
using YY.Admin.Views;
using System.Windows.Controls;
using YY.Admin.Core.SqlSugar;
using YY.Admin.Application.Service;
using YY.Admin.Core;
using Microsoft.Extensions.Configuration;
using System.IO;
using NewLife.Caching;
using SqlSugar;
using Microsoft.Extensions.Options;
using YY.Admin.Core.Option;
using Prism.Ioc;
using Microsoft.Identity.Client;
using System.Configuration;
using NewLife.Caching.Services;
using YY.Admin.Setup;
namespace YY.Admin
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        private IConfiguration _configuration;
        protected override Window CreateShell()
        {
            return Container.Resolve<LoginWindow>();
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            // 构建配置
            _configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("./Configuration/appsettings.json", optional: false, reloadOnChange: true)
                .Build();
            base.OnStartup(e);
        }
        //注册
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            //项目配置选项
            containerRegistry.AddProjectOptions(_configuration);
            // 注册缓存服务
            containerRegistry.AddNewLifeCache(_configuration);
            // 注册数据库上下文
            containerRegistry.RegisterSingleton<ISqlSugarDbContext, SqlSugarDbContext>();

            // 服务注册
            containerRegistry.RegisterSingleton<ISysAuthService, SysAuthService>();
            containerRegistry.RegisterSingleton<ISysUserService, SysUserService>();

            // 注册所有需要导航的视图
            containerRegistry.RegisterForNavigation<DashboardView>("DashboardView");
            containerRegistry.RegisterForNavigation<UserManagementView>("UserManagementView");
            //containerRegistry.RegisterForNavigation<RoleManagementView>("RoleManagementView");
            //containerRegistry.RegisterForNavigation<PermissionManagementView>("PermissionManagementView");
            //containerRegistry.RegisterForNavigation<OrderManagementView>("OrderManagementView");
            //containerRegistry.RegisterForNavigation<ProductManagementView>("ProductManagementView");
            //containerRegistry.RegisterForNavigation<ReportView>("ReportView");
            //containerRegistry.RegisterForNavigation<MonitorView>("MonitorView");

            // 窗口注册
            containerRegistry.RegisterForNavigation<LoginWindow, LoginViewModel>();
            containerRegistry.RegisterForNavigation<MainWindow, MainViewModel>();
        }
      

    }

}
